﻿<internals:PageBase
    x:Class="JV.Com.Views.NewsListPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:dvm="using:JV.Com.DesignViewModels"
    xmlns:internals="using:JV.Com.Internals"
    xmlns:interactivity="using:Microsoft.Xaml.Interactivity"
    xmlns:core="using:Microsoft.Xaml.Interactions.Core"
    mc:Ignorable="d" x:Name="pageRoot"
    xmlns:converters="using:JV.Com.Converters"
    xmlns:wrappers="using:JV.Com.Views.Wrapper"
    xmlns:prism="using:Microsoft.Practices.Prism.StoreApps"
    prism:ViewModelLocator.AutoWireViewModel="true">
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="140" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <Border BorderBrush="{StaticResource DataItemBorderThemeBrush}" VerticalAlignment="Stretch"
                Background="White" BorderThickness="0, 1, 0, 0"  Grid.Row="1">
            <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="350" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>

            <!-- Liste des news -->
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" x:Name="NewsListScroll"
                            BorderThickness="0, 0, 1, 0" BorderBrush="{StaticResource DataItemBorderThemeBrush}"
                            Background="{StaticResource DataItemBackgroundThemeBrush}" ZoomMode="Disabled">
                <ListView ItemsSource="{Binding News}" SelectionMode="Single" x:Name="NewsList"
                        SelectedIndex="{Binding SelectedNewsIndex, Mode=TwoWay}" ScrollViewer.VerticalScrollBarVisibility="Visible" >
                    <ListView.ItemTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="100" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <Border BorderBrush="{StaticResource DataItemBorderThemeBrush}" BorderThickness="1" Margin="0, 0, 5, 0">
                                    <Image Source="{Binding ImageUrl}" Stretch="UniformToFill"
                                            VerticalAlignment="Center" HorizontalAlignment="Center" />
                                </Border>
                                <TextBlock Text="{Binding Title}" Grid.Column="1" TextWrapping="Wrap"
                                            Style="{StaticResource LittleItemTextBlockStyle}" />
                            </Grid>
                        </DataTemplate>
                    </ListView.ItemTemplate>
                    <ListView.ItemContainerStyle>
                        <Style TargetType="ListViewItem" BasedOn="{StaticResource NewsListViewItemStyle}">
                            <Setter Property="Margin" Value="0" />
                        </Style>
                    </ListView.ItemContainerStyle>
                    <ListView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <ItemsWrapGrid ItemHeight="100" ItemWidth="350"/>
                        </ItemsPanelTemplate>
                    </ListView.ItemsPanel>
                </ListView>
            </ScrollViewer>
                
            <Grid Grid.Column="1" VerticalAlignment="Stretch">
                <Grid.Transitions>
                    <TransitionCollection>
                        <ContentThemeTransition />
                    </TransitionCollection>
                </Grid.Transitions>

                <FlipView ItemsSource="{Binding News}" SelectedIndex="{Binding SelectedNewsIndex, Mode=TwoWay}"
                                SelectionChanged="News_SelectionChanged">
                    <FlipView.ItemTemplate>
                        <DataTemplate>
                            <wrappers:DetailNewsWrapper DataContext="{Binding}" />
                        </DataTemplate>
                    </FlipView.ItemTemplate>
                </FlipView>
            </Grid>
                
        </Grid>
        </Border>
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="120"/>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Button  x:Name="backButton" Style="{StaticResource NavigationBackButtonNormalStyle}"
                            Margin="39,59,39,0" VerticalAlignment="Top"
                            Command="{Binding GoBackCommand}"
                            AutomationProperties.Name="Back"
                            AutomationProperties.AutomationId="BackButton"
                            AutomationProperties.ItemType="Navigation Button"/>
            <TextBlock x:Name="pageTitle" Text="{Binding PageTitle}" Style="{StaticResource HeaderTextBlockStyle}" Grid.Column="1"
                        VerticalAlignment="Bottom" Margin="0,0,30,40" IsHitTestVisible="false" TextWrapping="NoWrap" />
            <SearchBox Grid.Column="2"
                        Height="35" Width="270" VerticalAlignment="Top"
                        PlaceholderText="Rechercher" QueryText="{Binding Query}"
                        SuggestionsRequested="SearchBox_SuggestionsRequested"
                        QuerySubmitted="SearchBox_QuerySubmitted" Margin="0, 63, 40, 0" />
        </Grid>
    </Grid>
</internals:PageBase>
